﻿using slaughters.Dto;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using Traceability.Commont.Domains.AnimalsDomainFiles;

namespace Butcher.winform.EnterpriseForms
{
    public partial class Eeduction : Form
    {
        public Eeduction()
        {
            InitializeComponent();
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            string url = @"http://localhost:5229/api/Section/DeductionsCreate";
            HttpClient client = new HttpClient();
            Deductions newDeductions = new Deductions();
            if (DeductionBusiness1.Checked)
            {
                newDeductions.DeductionBusiness = "活畜管理";
            }
            if (DeductionBusiness2.Checked)
            {
                newDeductions.DeductionBusiness = "屠宰管理";
            }
            newDeductions.DuctionName = DuctionNamed.Text;
            newDeductions.DEductionRemark = DEductionRemarkd.Text;
            newDeductions.Price =Convert.ToDecimal(DeductionPrice.Text);
            newDeductions.Stact = 0;
            newDeductions.Ductionid = 0;
            var content = new StringContent(JsonSerializer.Serialize<Deductions>(newDeductions));
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type","application/json");
            string result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
            if(result!=null)
            {
                MessageBox.Show("添加成功");
            }
        }
    }
}
